import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author LiuYan
 * @date 2023/5/8
 *
 * Java 10中新增copyOf方法返回不可变的集合
 */
public class ImmutableCollectionOptimization {

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        // Map.copyOf() Set.copyOf() List.copyOf()均返回不可变集合
        List<Integer> immutableList = List.copyOf(list);
        System.out.println(immutableList);
    }
}
